package backend.Register;

public class physicalReg extends RISCVreg{
    private int index;
    private String name;

    public physicalReg(String name) {
        this.name = name;
        switch(name){
            case "zero":
                this.index= 0;
                break;
            case "ra":
                this.index= 1;
                break;
            case "sp":
                this.index= 2;
                break;
            case "gp":
                this.index= 3;
                break;
            case "tp":
                this.index= 4;
                break;
            case "t0":
                this.index= 5;
                break;
            case "t1":
                this.index= 6;
                break;
            case "t2":
                this.index= 7;
                break;
            case "s0":
                this.index= 8;
                break;
            case "s1":
                this.index= 9;
                break;
            case "a0":
                this.index= 10;
                break;
            case "a1":
                this.index= 11;
                break;
            case "a2":
                this.index= 12;
                break;
            case "a3":
                this.index= 13;
                break;
            case "a4":
                this.index= 14;
                break;
            case "a5":
                this.index= 15;
                break;
            case "a6":
                this.index= 16;
                break;
            case "a7":
                this.index= 17;
                break;
            case "s2":
                this.index= 18;
                break;
            case "s3":
                this.index= 19;
                break;
            case "s4":
                this.index= 20;
                break;
            case "s5":
                this.index= 21;
                break;
            case "s6":
                this.index= 22;
                break;
            case "s7":
                this.index= 23;
                break;
            case "s8":
                this.index= 24;
                break;
            case "s9":
                this.index= 25;
                break;
            case "s10":
                this.index= 26;
                break;
            case "s11":
                this.index= 27;
                break;
            case "t3":
                this.index= 28;
                break;
            case "t4":
                this.index= 29;
                break;
            case "t5":
                this.index= 30;
                break;
            case "t6":
                this.index= 31;
                break;
        }
        setColor(this.index);
    }

    public int getIndex() {
        return index;
    }

    public boolean isSReg(){
        //函数调用的
        return index == 8 || index == 9 || (index >= 18 && index <= 27);
    }

    public String getName() {
        return name;
    }

    public String toString() {
        return name;
    }
}
